<template>
  <div class="main">
    <!-- <div class="main-header">
      <a href class="main-header-logo">
        <img :src="logo" alt />
        <span>我爱报销</span>
      </a>
      <van-icon v-if="isSetShow" name="setting-o" class="icon-set" @click="goSet" /> 
    </div>-->
    <!-- <router-view></router-view> -->
      <router-view></router-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      logo: require("@/assets/img/logo.png"),
      title: "",
    };
  },

  watch: {},
  mounted() {
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }

    var isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

    if (isiOS) {
      //在页面刷新时将vuex里的信息保存到缓存里
      window.addEventListener("pagehide", () => {
        sessionStorage.setItem("store", JSON.stringify(this.$store.state));
      });
    } else {
      //在页面刷新时将vuex里的信息保存到缓存里
      window.addEventListener("beforeunload", () => {
        sessionStorage.setItem("store", JSON.stringify(this.$store.state));
      });
    }

  },
  computed: {
    isSetShow() {
      let arr = ["/login", "/home", "/userSet"];

      if (arr.includes(this.$route.path)) {
        return false;
      } else {
        return true;
      }
    },
  },
  methods: {
    goSet() {
      this.$router.push({
        path: "/userSet",
      });
    },
  },
};
</script>

<style lang='less'>
.main {
  width: 100%;
  height: 100%;
  // padding-top: 60px;
  box-sizing: border-box;
  margin: auto;
  &-header {
    // height: 60px;
    width: 100%;
    font-size: 16px;
    // box-shadow: 0px 5px 10px 0px rgba(211, 211, 211, 0.5);
    padding: 0 10px 0 15px;
    box-sizing: border-box;
    position: fixed;
    background: #fff;
    top: 0;
    z-index: 2020;
  }
  &-header-logo {
    display: inline-block;
    text-decoration: none;
    height: 100%;
    line-height: 60px;
    > img {
      width: 60px;
      height: 30px;
      object-fit: contain;
      vertical-align: middle;
      margin-right: 8px;
    }
    > span {
      font-size: 16px;
      font-weight: 800;
      color: rgba(53, 53, 53, 1);
    }
  }
  .icon-set {
    font-size: 18px;
    vertical-align: middle;
    color: #2878ff;
    position: absolute;
    right: 10px;
    top: 50%;
    margin-top: -9px;
  }
}
</style>
